package com.engine4cloud.tdf.supervision.controller.web;

import com.engine4cloud.tdf.common.core.util.R;
import com.engine4cloud.tdf.common.data.web.response.PageInfo;
import com.engine4cloud.tdf.common.data.web.response.Params;
import com.engine4cloud.tdf.supervision.dto.query.AreaFenceQueryDTO;
import com.engine4cloud.tdf.supervision.dto.result.AreaFenceResultDTO;
import com.engine4cloud.tdf.supervision.service.AreaFenceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

/**
 * 行政区划电子围栏
 *
 * @author wenjie
 * @date 2024-04-22 22:40:06
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/web/area/fence")
@Tag(description = "AreaFence", name = "行政区划电子围栏管理-web")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class AreaFenceWebController {

    private final AreaFenceService sysAreaFenceService;

    /**
     * 分页查询
     *
     * @param page 分页对象
     * @return R<?>
     */
    @Operation(summary = "分页查询", description = "分页查询")
    @PostMapping("/page")
    public R<PageInfo<AreaFenceResultDTO>> getFirstFloorChildren(@ParameterObject Params page, @Valid @RequestBody AreaFenceQueryDTO dto) {
        return R.ok(sysAreaFenceService.pageList(page, dto));
    }

    /**
     * 详情
     *
     * @param code 围栏编号
     * @return R<?>
     */
    @Operation(summary = "详情", description = "详情")
    @GetMapping("/detail")
    public R<AreaFenceResultDTO> detail(@Schema(description = "围栏编号", example = "460000") @ParameterObject String code) {
        return R.ok(sysAreaFenceService.getByCode(code));
    }

    /**
     * 根据编号列表查询
     *
     * @param code 围栏编号
     * @return R<?>
     */
    @Operation(summary = "根据编号列表查询", description = "根据编号列表查询")
    @GetMapping("/find")
    public R<AreaFenceResultDTO> find(@Schema(description = "围栏编号", example = "460000") @ParameterObject String code) {
        return R.ok(sysAreaFenceService.getByCode(code));
    }
}
